<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

class CreateCodeRecordsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('code_records', function (Blueprint $table) {
            $table->id();
            $table->integer('store_id')->unsigned()->default(0)->comment('店铺id');
            $table->integer('user_id')->unsigned()->default(0)->comment('用户id, 未登录写0');
            $table->string('phone')->comment('手机号');
            $table->string('code')->comment('短信验证码');
            $table->tinyInteger('type')->default(1)->comment('验证码类型 (注册1 / 登录2 / 忘记密码3 / 设置手机4 / 设置密码5');
            $table->datetime('expire_at')->comment('验证码过期时间');
            $table->timestamps();
        });

        DB::statement("ALTER TABLE `code_records` comment '短信发送记录表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('code_records');
    }
}
